#include <iostream>
#include <string.h>
using namespace std;
class Network{
		public:
			void set();
			void start();
			void stop();
			void hellowin();
			void show();	
//		private:
			std::string ssid;
			std::string password;
//			std::string keyline;
	}Share;

//Network share;

void Network::set()
{	
	cout << "Wifi name(English only): "; 
	cin >> Share.ssid;
	cout << "Password(8 digits at least): ";
	cin >> Share.password;
	if (Share.password.length() >= 8 ) {
		cout << "SSID: " << Share.ssid << endl;
		cout << "Password: " << Share.password << endl; 
		cout << "Set Successfully!" << endl;		
	} else cout << "Set Failed!\nLength of Password must be equal or greater than 8 digits!" << endl;

	system("pause");
	Share.hellowin();
}

void Network::start()
{
	string output = "netsh wlan set hostednetwork mode=allow ssid=" + Share.ssid + " key=" + Share.password;
	const char *output_char = output.c_str();
	system(output_char);
	system("netsh wlan start hostednetwork");
	system("pause");
	Share.hellowin();
	
}
void Network::show()
{
	system("netsh wlan show hostednetwork");
	system("pause");
	Share.hellowin();
}
void Network::stop()
{
	system("netsh wlan stop hostednetwork");
	system("pause");
	Share.hellowin();
}

void Network::hellowin()
{
	system("cls");
//	Share.ssid = "FreeWifi";
//	Share.password = "123456789000";
	std::cout << "************************************\n";
	std::cout << "*                                  *\n";
	std::cout << "* Welcome to the Network Share 1.0 *\n";
	std::cout << "*                                  *\n";
	std::cout << "************************************\n\n";
	
	std::cout << "Please choose the function you are going to do:\n";	std::cout << "1.The welcome home page\n";
	std::cout << "2.Set the SSID and PASSWORD\n";
	std::cout << "3.Start the WI-FI sharing\n";
	std::cout << "4.Show the device connection\n";
	std::cout << "5.Stop the WI-FI sharing\n";
	
	int choice;
	
	std::cin >> choice;
	
	switch (choice){
		case 1: 
			Network::hellowin();
			break;
		case 2:
			Network::set();
			break;
		case 3:
			Network::start();
			break;
		case 4:
			Network::show();
			break;
		case 5:
			Network::stop();
			break;
		default:
			std::cout << "ERROR INPUT!\n";
			Share.hellowin();
			break;		
	}
}

int main()
{	
	system("mode con cols=50 lines=20"); 
	Share.ssid = "FreeWifi";
	Share.password = "123456789000";
	Share.hellowin();
	system("pause");
	return 0;
 } 
 
